package com.pet.shop.controller.room;

import com.pet.shop.dto.PageDto;
import com.pet.shop.entity.room.Hotel;
import com.pet.shop.service.room.IHotelService;
import com.pet.shop.utils.ApiResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/api/room")
@RestController
public class RoomApiController {

    @Autowired
    private IHotelService roomService;

    /**
     * 分页查找
     * @param pageDto
     * @return
     */
    @RequestMapping("page")
    public Map<String, Object> queryPage(@RequestBody PageDto<Hotel> pageDto){
        pageDto = roomService.queryPage(pageDto);
        return ApiResultUtil.success_page(pageDto);
    }

    /**
     * 新增预约
     * @param room
     * @return
     */
    @RequestMapping("insert")
    public Map<String, Object> insertRoom(@RequestBody Hotel room){
        room = roomService.insertEntity(room);
        return ApiResultUtil.success_data(room);
    }
}
